package thread_pool;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/23
 * Time:11:38
 **/
public class PoolDemo20 {
    //实现2个Date（时间类型）的格式化
    public static void main(String[] args) {
        Date date = new Date();
        System.out.println("未格式化前"+date);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String result = dateFormat.format(date);
        System.out.println("未格式化后"+result);

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                Date date1 = new Date(1000);
                myFormatTime(date1);
            }
        });
        t1.start();

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                Date date2 = new Date(2000);
                myFormatTime(date2);
            }
        });
        t2.start();
    }

    /**
     * 自定义格式化时间
     * @param date 时间
     */
    private static void myFormatTime(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("mm:ss");
        String result = simpleDateFormat.format(date);
        System.out.println("时间"+result);
    }
}
